<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>山芋头</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="记录和总结让知识得到积累，分享能创造价值">
<meta property="og:type" content="website">
<meta property="og:title" content="山芋头">
<meta property="og:url" content="https://bianchengme.gitee.io/page/6/index.html">
<meta property="og:site_name" content="山芋头">
<meta property="og:description" content="记录和总结让知识得到积累，分享能创造价值">
<meta property="og:locale" content="cn">
<meta property="article:author" content="jmme@foxmail.com">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="山芋头" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">山芋头</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">记录和分享能创造价值</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://bianchengme.gitee.io"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-iOS常见算法汇总" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/03/05/iOS%E5%B8%B8%E8%A7%81%E7%AE%97%E6%B3%95%E6%B1%87%E6%80%BB/" class="article-date">
  <time datetime="2019-03-05T02:28:42.000Z" itemprop="datePublished">2019-03-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/iOS/">iOS</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2019/03/05/iOS%E5%B8%B8%E8%A7%81%E7%AE%97%E6%B3%95%E6%B1%87%E6%80%BB/">iOS常见算法汇总</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="算法相关"><a href="#算法相关" class="headerlink" title="算法相关"></a>算法相关</h1><ul>
<li>字符串反转</li>
<li>链表反转</li>
<li>有序数组合并</li>
<li>Hash算法</li>
<li>查找两个子视图的共同父视图</li>
<li>求无序数组当中的中位数</li>
</ul>
<p><a href="https://github.com/shanyutou/ALGforC" target="_blank" rel="noopener">github地址</a></p>
<h2 id="1-字符串反转"><a href="#1-字符串反转" class="headerlink" title="1.字符串反转"></a>1.字符串反转</h2><p>给定字符串 “Hello,world”实现将其反转。输出“dlrow,olleh”。</p>
<p>思路：字符串数组中从开始收尾交换，一直到中间元素，实现数组反转；</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">char</span> ch[] = <span class="string">"hello,world"</span>;</span><br><span class="line"><span class="keyword">char</span> *<span class="built_in">begin</span> = ch;</span><br><span class="line"><span class="keyword">char</span> *<span class="built_in">end</span> = ch + <span class="built_in">strlen</span>(ch) - <span class="number">1</span>;</span><br><span class="line"><span class="keyword">while</span> (<span class="built_in">begin</span> &lt; <span class="built_in">end</span>) &#123;</span><br><span class="line">    <span class="keyword">char</span> temp = *<span class="built_in">begin</span>;</span><br><span class="line">    *(<span class="built_in">begin</span>++) = *<span class="built_in">end</span>;</span><br><span class="line">    *(<span class="built_in">end</span>--) = temp;</span><br><span class="line">&#125;</span><br><span class="line"><span class="built_in">printf</span>(<span class="string">"reverseString:%s\n"</span>, ch);</span><br></pre></td></tr></table></figure>

<h2 id="2-链表反转"><a href="#2-链表反转" class="headerlink" title="2.链表反转"></a>2.链表反转</h2><p>反转前1-&gt;2-&gt;3-&gt;4-&gt;NULL<br>反转后4-&gt;3-&gt;2-&gt;1-&gt;NULL</p>
<p>思路：因为链表是从头到尾遍历，想要反转，最方便的就是构造链表从尾部到头部的顺序构造。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**  定义一个链表  */</span></span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Node</span> &#123;</span></span><br><span class="line">    </span><br><span class="line">    NSInteger data;</span><br><span class="line">    </span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> * <span class="title">next</span>;</span></span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line">- (<span class="keyword">void</span>)listReverse</span><br><span class="line">&#123;</span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> * <span class="title">p</span> = [<span class="title">self</span> <span class="title">constructList</span>];</span></span><br><span class="line">    </span><br><span class="line">    [self printList:p];</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//反转后的链表头部</span></span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> * <span class="title">newH</span> = <span class="title">NULL</span>;</span></span><br><span class="line">    <span class="comment">//头插法</span></span><br><span class="line">    <span class="keyword">while</span> (p != <span class="literal">NULL</span>) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">//记录下一个结点</span></span><br><span class="line">        <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> * <span class="title">temp</span> = <span class="title">p</span>-&gt;<span class="title">next</span>;</span></span><br><span class="line">        <span class="comment">//当前结点的next指向新链表的头部</span></span><br><span class="line">        p-&gt;next = newH;</span><br><span class="line">        <span class="comment">//更改新链表头部为当前结点</span></span><br><span class="line">        newH = p;</span><br><span class="line">        <span class="comment">//移动p到下一个结点</span></span><br><span class="line">        p = temp;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    [self printList:newH];</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> 打印链表</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment"> @param head 给定链表</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">- (<span class="keyword">void</span>)printList:(struct Node *)head</span><br><span class="line">&#123;</span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> * <span class="title">temp</span> = <span class="title">head</span>;</span></span><br><span class="line">    </span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"list is : "</span>);</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">while</span> (temp != <span class="literal">NULL</span>) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">"%zd "</span>,temp-&gt;data);</span><br><span class="line">        </span><br><span class="line">        temp = temp-&gt;next;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">/**  构造链表  */</span></span><br><span class="line">- (struct Node *)constructList</span><br><span class="line">&#123;</span><br><span class="line">    <span class="comment">//头结点</span></span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> *<span class="title">head</span> = <span class="title">NULL</span>;</span></span><br><span class="line">    <span class="comment">//尾结点</span></span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> *<span class="title">cur</span> = <span class="title">NULL</span>;</span></span><br><span class="line">    </span><br><span class="line">    <span class="keyword">for</span> (NSInteger i = <span class="number">0</span>; i &lt; <span class="number">10</span>; i++) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> *<span class="title">node</span> = <span class="title">malloc</span>(<span class="title">sizeof</span>(<span class="title">struct</span> <span class="title">Node</span>));</span></span><br><span class="line">        </span><br><span class="line">        node-&gt;data = i;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">//头结点为空，新结点即为头结点</span></span><br><span class="line">        <span class="keyword">if</span> (head == <span class="literal">NULL</span>) &#123;</span><br><span class="line">            </span><br><span class="line">            head = node;</span><br><span class="line">            </span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            <span class="comment">//当前结点的next为尾结点</span></span><br><span class="line">            cur-&gt;next = node;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">//设置当前结点为新结点</span></span><br><span class="line">        cur = node;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">return</span> head;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="3-有序数组合并"><a href="#3-有序数组合并" class="headerlink" title="3.有序数组合并"></a>3.有序数组合并</h2><p>将有序数组 和 合并为</p>
<p>思路：两个数组一起遍历，选择合适的（比较小的）。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="keyword">void</span>)orderListMerge</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">int</span> aLen = <span class="number">5</span>,bLen = <span class="number">9</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">int</span> a[] = &#123;<span class="number">1</span>,<span class="number">4</span>,<span class="number">6</span>,<span class="number">7</span>,<span class="number">9</span>&#125;;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">int</span> b[] = &#123;<span class="number">2</span>,<span class="number">3</span>,<span class="number">5</span>,<span class="number">6</span>,<span class="number">8</span>,<span class="number">9</span>,<span class="number">10</span>,<span class="number">11</span>,<span class="number">12</span>&#125;;</span><br><span class="line">    </span><br><span class="line">    [self printList:a length:aLen];</span><br><span class="line">    </span><br><span class="line">    [self printList:b length:bLen];</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">int</span> result[<span class="number">14</span>];</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">int</span> p = <span class="number">0</span>,q = <span class="number">0</span>,i = <span class="number">0</span>;<span class="comment">//p和q分别为a和b的下标，i为合并结果数组的下标</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">//任一数组没有达到s边界则进行遍历</span></span><br><span class="line">    <span class="keyword">while</span> (p &lt; aLen &amp;&amp; q &lt; bLen) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">//如果a数组对应位置的值小于b数组对应位置的值,则存储a数组的值，并移动a数组的下标与合并结果数组的下标</span></span><br><span class="line">        <span class="keyword">if</span> (a[p] &lt; b[q]) result[i++] = a[p++];</span><br><span class="line">        </span><br><span class="line">        <span class="comment">//否则存储b数组的值，并移动b数组的下标与合并结果数组的下标</span></span><br><span class="line">        <span class="keyword">else</span> result[i++] = b[q++];</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//如果a数组有剩余，将a数组剩余部分拼接到合并结果数组的后面</span></span><br><span class="line">    <span class="keyword">while</span> (++p &lt; aLen) &#123;</span><br><span class="line">        </span><br><span class="line">        result[i++] = a[p];</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//如果b数组有剩余，将b数组剩余部分拼接到合并结果数组的后面</span></span><br><span class="line">    <span class="keyword">while</span> (q &lt; bLen) &#123;</span><br><span class="line">        </span><br><span class="line">        result[i++] = b[q++];</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    [self printList:result length:aLen + bLen];</span><br><span class="line">&#125;</span><br><span class="line">- (<span class="keyword">void</span>)printList:(<span class="keyword">int</span> [])<span class="built_in">list</span> length:(<span class="keyword">int</span>)length</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; length; i++) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">"%d "</span>,<span class="built_in">list</span>[i]);</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="4-HASH算法"><a href="#4-HASH算法" class="headerlink" title="4.HASH算法"></a>4.HASH算法</h2><ul>
<li><p>哈希表</p>
</li>
<li><p>在一个字符串中找到第一个只出现一次的字符。如输入“fsfsbcd”,输出”b”;</p>
</li>
</ul>
<p>思路：字符（char）是一个长度为8的数据类型，因此总共有256中可能。每个字母根据其ASC||码值作为组数下标对应数组中的一个数字。数组中存储每次字符出现的次数。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="keyword">void</span>)hashTest</span><br><span class="line">&#123;</span><br><span class="line">    NSString * testString = @<span class="string">"hhaabccdeef"</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">char</span> testCh[<span class="number">100</span>];</span><br><span class="line">    </span><br><span class="line">    <span class="built_in">memcpy</span>(testCh, [testString cStringUsingEncoding:NSUTF8StringEncoding], [testString length]);</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">int</span> <span class="built_in">list</span>[<span class="number">256</span>];</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; <span class="number">256</span>; i++) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="built_in">list</span>[i] = <span class="number">0</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">char</span> *p = testCh;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">char</span> result = <span class="string">'\0'</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">while</span> (*p != result) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="built_in">list</span>[*(p++)]++;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    p = testCh;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">while</span> (*p != result) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="keyword">if</span> (<span class="built_in">list</span>[*p] == <span class="number">1</span>) &#123;</span><br><span class="line"></span><br><span class="line">            result = *p;</span><br><span class="line">            </span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        p++;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"result:%c"</span>,result);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="5-查找两个子视图的共同父视图"><a href="#5-查找两个子视图的共同父视图" class="headerlink" title="5.查找两个子视图的共同父视图"></a>5.查找两个子视图的共同父视图</h2><p>思路:分别记录两个子视图的所有父视图并保存到数组中，然后倒序寻找,直至找到第一个不一样的父视图。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="keyword">void</span>)findCommonSuperViews:(UIView *)view1 view2:(UIView *)view2</span><br><span class="line">&#123;</span><br><span class="line">    NSArray * superViews1 = [self findSuperViews:view1];</span><br><span class="line">    </span><br><span class="line">    NSArray * superViews2 = [self findSuperViews:view2];</span><br><span class="line">    </span><br><span class="line">    NSMutableArray * resultArray = [NSMutableArray <span class="built_in">array</span>];</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">int</span> i = <span class="number">0</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">while</span> (i &lt; MIN(superViews1.count, superViews2.count)) &#123;</span><br><span class="line">        </span><br><span class="line">        UIView *super1 = superViews1[superViews1.count - i - <span class="number">1</span>];</span><br><span class="line">        </span><br><span class="line">        UIView *super2 = superViews2[superViews2.count - i - <span class="number">1</span>];</span><br><span class="line">        </span><br><span class="line">        <span class="keyword">if</span> (super1 == super2) &#123;</span><br><span class="line">            </span><br><span class="line">            [resultArray addObject:super1];</span><br><span class="line">            </span><br><span class="line">            i++;</span><br><span class="line">            </span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            </span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    NSLog(@<span class="string">"resultArray:%@"</span>,resultArray);</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line">- (NSArray &lt;UIView *&gt;*)findSuperViews:(UIView *)view</span><br><span class="line">&#123;</span><br><span class="line">    UIView * temp = view.superview;</span><br><span class="line">    </span><br><span class="line">    NSMutableArray * result = [NSMutableArray <span class="built_in">array</span>];</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">while</span> (temp) &#123;</span><br><span class="line">        </span><br><span class="line">        [result addObject:temp];</span><br><span class="line">        </span><br><span class="line">        temp = temp.superview;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">return</span> result;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="6-求无序数组中的中位数"><a href="#6-求无序数组中的中位数" class="headerlink" title="6.求无序数组中的中位数"></a>6.求无序数组中的中位数</h2><p>中位数：当数组个数n为奇数时，为(n + 1)/2，即是最中间那个数字；当n为偶数时，为(n/2 + (n/2 + 1))/2,即是中间两个数字的平均数。</p>
<p>思路:</p>
<p>1.排序算法+中位数<br>首先用冒泡排序、快速排序、堆排序、希尔排序等排序算法将所给数组排序，然后取出其中位数即可。<br>2.利用快排思想</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://bianchengme.gitee.io/2019/03/05/iOS%E5%B8%B8%E8%A7%81%E7%AE%97%E6%B3%95%E6%B1%87%E6%80%BB/" data-id="cktcaskhr002k3guccggt36tt" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/iOS/" rel="tag">iOS</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-UI-为什么必须要在主线程更新" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/03/01/UI-%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BF%85%E9%A1%BB%E8%A6%81%E5%9C%A8%E4%B8%BB%E7%BA%BF%E7%A8%8B%E6%9B%B4%E6%96%B0/" class="article-date">
  <time datetime="2019-03-01T11:58:22.000Z" itemprop="datePublished">2019-03-01</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/iOS/">iOS</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2019/03/01/UI-%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BF%85%E9%A1%BB%E8%A6%81%E5%9C%A8%E4%B8%BB%E7%BA%BF%E7%A8%8B%E6%9B%B4%E6%96%B0/">UI 为什么必须要在主线程更新</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>在iOS开发中，一直知道不能再子线程中更新UI，但是被面试官问到为什么不能再子线程中更新UI,却不知道了尴尬，这就是学习不探究原理的的毛病，要治。</p>
<p>UIKit 官方文档中有重点提示： </p>
<p><strong>Important</strong></p>
<p>Use UIKit classes only from your app’s main thread or main dispatch queue, unless otherwise indicated. This restriction particularly applies to classes derived from UIResponder or that involve manipulating your app’s user interface in any way.</p>
<p>意思就是只能在主线程或者主队列中使用UIKit类，特别适用于派生自UIPResponder的类，或者涉及到以任何方式操纵应用程序的用户界面。</p>
<p>我们探究背后的原因是什么？</p>
<p>UIKit并不是一个线程安全的类，UI操作涉及到渲染访问各种View对象的属性，如果异步操作下会存在读写问题，而为其加锁则会耗费大量资源并拖慢运行速度。另一方面因为整个程序的起点UIApplication是在主线程进行初始化，所有的用户事件都是在主线程上进行传递（如点击、拖动），所以view只能在主线程上才能对事件进行响应。而在渲染方面由于图像的渲染需要以60帧的刷新率在屏幕上同时更新，在非主线程异步化的情况下无法确定这个处理过程能够实现同步更新。</p>
<p><strong>UIKit非线程安全</strong></p>
<p>在UIKit中，很多类中大部分的属性都被修饰为nonatomic，这意味着它们不能在多线程的环境下工作，而对于UIKit这样一个庞大的框架，将其所有属性都设计为线程安全是不现实的，这可不仅仅是简单的将nonatomic改成atomic或者是加锁解锁的操作，还涉及到很多的方面：</p>
<p>假设能够异步设置view的属性，那我们究竟是希望这些改动能够同时生效，还是按照各自runloop的进度去改变这个view的属性呢？</p>
<p>假设UITableView在其他线程去移除了一个cell，而在另一个线程却对这个cell所在的index进行一些操作，这时候可能就会引发crash。</p>
<p>如果在后台线程移除了一个view，这个时候runloop周期还没有完结，用户在主线程点击了这个“将要”消失的view，那么究竟该不该响应事件？在哪条线程进行响应？</p>
<p>仔细思考，似乎能够多线程处理UI并没有给我们开发带来更多的便利，假如你代入了这些情景进行思考，你很容易得出一个结论： “我在一个串行队列对这些事件进行处理就可以了。” 苹果也是这样想的，所以UIKit的所有操作都要放到主线程串行执行。</p>
<p>在Thread-Safe Class Design一文提到：</p>
<p>It’s a conscious design decision from Apple’s side to not have UIKit be thread-safe. Making it thread-safe wouldn’t buy you much in terms of performance; it would in fact make many things slower. And the fact that UIKit is tied to the main thread makes it very easy to write concurrent programs and use UIKit. All you have to do is make sure that calls into UIKit are always made on the main thread.</p>
<p>大意为把UIKit设计成线程安全并不会带来太多的便利，也不会提升太多的性能表现，甚至会因为加锁解锁而耗费大量的时间。事实上并发编程也没有因为UIKit是线程不安全而变得困难，我们所需要做的只是要确保UI操作在主线程进行就可以了。</p>
<p><strong>Runloop 与绘图循环</strong></p>
<p>道理我们都懂，那这个究竟跟我们不能在后台线程操作UI有什么关系呢？</p>
<p>UIApplication在主线程所初始化的Runloop我们称为Main Runloop，它负责处理app存活期间的大部分事件，如用户交互等，它一直处于不断处理事件和休眠的循环之中，以确保能尽快的将用户事件传递给GPU进行渲染，使用户行为能够得到响应，画面之所以能够得到不断刷新也是因为Main Runloop在驱动着。</p>
<p>而每一个view的变化的修改并不是立刻变化，相反的会在当前run loop的结束的时候统一进行重绘，这样设计的目的是为了能够在一个runloop里面处理好所有需要变化的view，包括resize、hide、reposition等等，所有view的改变都能在同一时间生效，这样能够更高效的处理绘制，这个机制被称为<strong>绘图循环（View Drawing Cycle)</strong>。</p>
<h2 id="理解iOS的渲染流程"><a href="#理解iOS的渲染流程" class="headerlink" title="理解iOS的渲染流程"></a>理解iOS的渲染流程</h2><h3 id="渲染系统框架"><a href="#渲染系统框架" class="headerlink" title="渲染系统框架"></a>渲染系统框架</h3><p><img src="uikit_stack.png" alt="uikit_stack.png"></p>
<ul>
<li>UIKit: 包含各种控件，负责对用户操作事件的响应，本身并不提供渲染的能力</li>
<li>Core Animation: 负责所有视图的绘制、显示与动画效果</li>
<li>OpenGL ES: 提供2D与3D渲染服务</li>
<li>Core Graphics: 提供2D渲染服务</li>
<li>Graphics Hardware: 指GPU</li>
</ul>
<p>所以在iOS中，所有视图的现实与动画本质上是由 Core Animation 负责，而不是UIKit。</p>
<h3 id="Core-Animation-Pipeline-流水线"><a href="#Core-Animation-Pipeline-流水线" class="headerlink" title="Core Animation Pipeline 流水线"></a>Core Animation Pipeline 流水线</h3><p><img src="core_animation_pipeline.png" alt="uikit_stack.png"></p>
<p>Core Animation的绘制是通过Core Animation Pipeline实现，它以流水线的形式进行渲染，具体分为四个步骤：</p>
<ul>
<li>Commit Transaction:</li>
</ul>
<p>可以细分为</p>
<pre><code>- Layout: 构建视图布局如addSubview等操作

- Display: 重载drawRect:进行时图绘制，该步骤使用CPU与内存

- Prepare: 主要处理图像的解码与格式转换等操作

- Commit: 将Layer递归打包并发送到Render Server</code></pre><ul>
<li><p>Render Server:</p>
<p>  负责渲染工作，会解析上一步Commit Transaction中提交的信息并反序列化成渲染树（render tree)，随后根据layer的各种属性生成绘制指令，并在下一次VSync信号到来时调用OpenGL进行渲染。</p>
</li>
<li><p>GPU:</p>
<p>  GPU会等待显示器的VSync信号发出后才进行OpenGL渲染管线，将3D几何数据转化成2D的像素图像和光栅处理，随后进行新的一帧的渲染，并将其输出到缓冲区。</p>
</li>
<li><p>Dispaly:</p>
<p>  从缓冲区中取出画面，并输出到屏幕上。</p>
</li>
</ul>
<h3 id="知识补充：iOS的VSync与双缓冲机制"><a href="#知识补充：iOS的VSync与双缓冲机制" class="headerlink" title="知识补充：iOS的VSync与双缓冲机制"></a>知识补充：iOS的VSync与双缓冲机制</h3><h4 id="VSync"><a href="#VSync" class="headerlink" title="VSync:"></a>VSync:</h4><p>VSync（vertical sync）是指垂直同步，在玩游戏的时候在设置的时候应该会看见过这个选项，这个机制能够让显卡和显示器保持在一个相同的刷新率从而避免画面撕裂。在iOS中，屏幕具有60Hz的刷新率，这意味着它每秒需要显示60张不同的图片（帧），但GPU并没有一个确定的刷新率，在某些时候GPU可能被要求更强力的数据输出来确保渲染能力，这时候他们可能比屏幕刷新率（60Hz）更快，就会导致屏幕不能完整的渲染所有GPU给他的数据，因为它不够快，屏幕的上一帧还没渲染完，下一帧就已经到来了，这就导致画面的撕裂。</p>
<p>这个时候我们就要引入VSync了，简单来说它就是让显卡保持他的输出速率不高于屏幕的刷新率，启用了VSync后，GPU不再会给你可怜的60Hz屏幕每秒发送100帧了，它会增加每一帧的发送间隔，确保显示器能够有充足的时间去处理每一帧。</p>
<h4 id="双缓冲机制"><a href="#双缓冲机制" class="headerlink" title="双缓冲机制"></a>双缓冲机制</h4><p>双缓冲机制是用于避免或减少画面闪烁的问题，在单缓冲的情况下，GPU输出了一帧画面，缓冲区就需要马上获取这个画面，并交给显示屏去显示，而这段时间GPU输出的画面就全都丢失了，因为没有缓冲区去承载这些画面，就会造成画面的闪烁。</p>
<p>而在双缓冲机制下有一个Back Frame Buffer和一个Front Frame Buffer，在GPU绘制完成后，它会将图像先保存到Back Frame Buffer中，操作完毕后，会调用一个交换函数，让绘制完成的Back Frame Buffer上的图像交换到Front Frame Buffer上。由于双缓冲利用了更多显存与CPU消耗时间，从而避免了画面的闪烁。</p>
<p>相信大家都会遇到过应用卡顿，卡顿的原因就是因为两帧的刷新时间间隔大于60帧每秒（约16.67ms），导致用户感觉点击或者滑动时，界面没有及时的响应。</p>
<p>前面提到Core Animation Pipeline是以流水线的形式工作的，在理想的状况下我们希望它能够在1/60s内完成图层树的准备工作并提交给渲染进程，而渲染进程在下一次VSync信号到来的时候提交给GPU进行渲染，并在1/60s内完成渲染，这样就不会产生任何的卡顿。</p>
<p>但是由于我们使用了我们的魔法UIKit，所以我们在许多后台线程进行了UI操作，在runloop的结尾准备进行渲染的时候，不同线程提交了不同的渲染信息，于是我们就拥有了更多的绘制事务，这个时候Core Animation Pipeline会不断将信息提交，让GPU进行渲染，由于绘制事件的不同步导致了GPU渲染的不同步，可能在上一帧是需要渲染一个label消失的画面，下一帧却又需要渲染这个label改变了文字，最终导致的是界面的不同步。</p>
<p>另一方面，在VSync和双缓冲机制我们可以看出渲染其实是一个十分消耗系统资源的操作（占用显存与CPU），所以可能会因为大量的事务和线程之间频繁的上下文切换导致了GPU无法处理，反而影响了性能，从而导致在1/60s中无法完成图层树的提交，导致了严重的卡顿。</p>
<h4 id="Texture-or-ComponentKit-实现支持异步更新UI框架"><a href="#Texture-or-ComponentKit-实现支持异步更新UI框架" class="headerlink" title="Texture or ComponentKit 实现支持异步更新UI框架"></a>Texture or ComponentKit 实现支持异步更新UI框架</h4><ul>
<li><p>AsyncDisplayKit（现命名为Texture） 是Facebook开源的一个用于保持iOS界面流畅的框架。</p>
</li>
<li><p>ComponentKit是Facebook开源的一个基于React思想的iOS原生UI开发框架。它通过函数式和声明的方式构建UI。</p>
</li>
</ul>
<p>让我们撤销掉我们对UIKit施展的各种魔法，回到这个UI只能在主线程进行操作的世界吧。这两个框架其实并不是真正的在后台线程操作UI，而是用了更巧妙的方法将一些耗时的操作异步执行，从而绕开了UIKit只能在主线程操作的限制。</p>
<p>比如Texture创建了各类Node，在node中包含了UIView，而Node本身是线程安全的，所以允许在后台线程对Node进行修改，随后在第一次主线程访问View的时候它才会在内部生成对应的View，当node的属性发生改变的时候，他也不会马上进行修改，而是在适当的时机一次性的在主线程为内部的View进行设置。（有点类似于绘图循环）</p>
<p>而ComponentKit则是通过创建Component来描述UI，它也是一个线程安全的类。可以将Component认为是一个刻板，而UIView是刻板下的一张纸，渲染则是喷墨的过程。当我们生成了一个Component的时候，就等于生成了一个View的模版，在进行渲染的时候只要按照模版进行绘制就可以了。复杂的界面可以通过各种简单的Component来组成。（类似于Flutter的widget）</p>
<h4 id="子线程中如何通知主线程（队列）更新UI方法，记录一下"><a href="#子线程中如何通知主线程（队列）更新UI方法，记录一下" class="headerlink" title="子线程中如何通知主线程（队列）更新UI方法，记录一下"></a>子线程中如何通知主线程（队列）更新UI方法，记录一下</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F;方法一</span><br><span class="line">[self performSelectorOnMainThread:@selector(updateImage:) withObject:data waitUntilDone:YES];</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;方法二</span><br><span class="line">dispatch_async(dispatch_get_main_queue(), ^&#123;</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;更新UI的代码，不用主线程中调用</span><br><span class="line"></span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;方法三</span><br><span class="line">[[NSOperationQueue mainQueue] addOperationWithBlock:^&#123;</span><br><span class="line"></span><br><span class="line">NSLog(@&quot;线程2：%@&quot;,[NSThread currentThread]);</span><br><span class="line"></span><br><span class="line">&#125;];</span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="https://bianchengme.gitee.io/2019/03/01/UI-%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BF%85%E9%A1%BB%E8%A6%81%E5%9C%A8%E4%B8%BB%E7%BA%BF%E7%A8%8B%E6%9B%B4%E6%96%B0/" data-id="cktcaskhh001h3gucfbkx3pmn" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/UI/" rel="tag">UI</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/iOS/" rel="tag">iOS</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-把Mac上好用的操作搬到Windows" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/02/26/%E6%8A%8AMac%E4%B8%8A%E5%A5%BD%E7%94%A8%E7%9A%84%E6%93%8D%E4%BD%9C%E6%90%AC%E5%88%B0Windows/" class="article-date">
  <time datetime="2019-02-26T08:28:22.000Z" itemprop="datePublished">2019-02-26</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Windows/">Windows</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2019/02/26/%E6%8A%8AMac%E4%B8%8A%E5%A5%BD%E7%94%A8%E7%9A%84%E6%93%8D%E4%BD%9C%E6%90%AC%E5%88%B0Windows/">把Mac上好用的操作搬到Windows</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>Mac电脑上有几个笔记喜欢的操作，换到Windows上没有很不习惯：有空格预览、方向快捷键、Alfred软件等。</p>
<p>Windows没有这些功能，但是Windows上有丰富的第三方软件可以实现上面的功能甚至能更丰富。</p>
<ul>
<li>QuickLook 点击空格快速预览文件；</li>
<li>AutoHotKey 无所不能的快捷键；</li>
<li>EveryThing 强大的文件搜索功能；</li>
<li>Wox 开源软件类似Alfred,可以安装插件；</li>
<li>Listary 类似Wox,收费软件用户体验更好，可以和Wox结合起来用；</li>
<li>Snipaste 挺方便的截屏工具；</li>
<li>Zeal 类似Dash的免费API工具，虽然比不上Dash好用；</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://bianchengme.gitee.io/2019/02/26/%E6%8A%8AMac%E4%B8%8A%E5%A5%BD%E7%94%A8%E7%9A%84%E6%93%8D%E4%BD%9C%E6%90%AC%E5%88%B0Windows/" data-id="cktcaskhz003p3gucbaxmdq44" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Windows/" rel="tag">Windows</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%B7%A5%E5%85%B7/" rel="tag">工具</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-mybatis-plus-xml-文件路径配置" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2018/10/31/mybatis-plus-xml-%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E9%85%8D%E7%BD%AE/" class="article-date">
  <time datetime="2018-10-31T12:12:30.000Z" itemprop="datePublished">2018-10-31</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/java/">java</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2018/10/31/mybatis-plus-xml-%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E9%85%8D%E7%BD%AE/">Maven项目资源文件路径配置理解</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>在Spring Boot中使用Mybatis Plus时遇到一个问题，在Mapper.java同目录下创建Mapper.xml文件，检查xml文件编写没有问题，application.yml文件中也配置了<code>mapper-locations: classpath:mapper/*.xml</code>,但是就是提示找不到xml文件。经过一番搜索，找到解决办法：在pom.xml 中 build 下添加：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">resources</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">resource</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">directory</span>&gt;</span>src/main/java<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">includes</span>&gt;</span></span><br><span class="line">                  <span class="tag">&lt;<span class="name">include</span>&gt;</span>**/*.xml<span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;/<span class="name">includes</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">resource</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">resources</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>重新运行就发现可以正常运行项目，学习不能止于知其然，要做到知其所以然，为什么添加该配置项目就能找到xml文件。初步分析，build的时候java目录下的xml文件没有被打包，找到一段关于maven打包resource配置介绍：</p>
<h3 id="1、介绍"><a href="#1、介绍" class="headerlink" title="1、介绍"></a>1、介绍</h3><p>构建Maven项目的时候，如果没有进行特殊的配置，Maven会按照标准的目录结构查找和处理各种类型文件。</p>
<p><code>src/main/java和src/test/java</code>这两个目录中的所有*.java文件会分别在comile和test-comiple阶段被编译，编译结果分别放到了target/classes和targe/test-classes目录中，但是这两个目录中的其他文件都会被忽略掉。</p>
<p><code>src/main/resouces和src/test/resources</code> 这两个目录中的文件也会分别被复制到target/classes和target/test-classes目录中。</p>
<p>然后打包插件默认会把<code>target/classes</code>这个目录中的所有内容打入到jar包或者war包中。这个初步解释了上面的问题所在。</p>
<h3 id="2、Maven项目的标准目录结构"><a href="#2、Maven项目的标准目录结构" class="headerlink" title="2、Maven项目的标准目录结构"></a>2、Maven项目的标准目录结构</h3><ul>
<li>src<pre><code>- main
        - java         源文件 
        - resources    资源文件
        - filters   资源过滤文件
        - config   配置文件
        - scripts   脚本文件
        - webapp   web应用文件
- test
        - java    测试源文件
        - resources    测试资源文件
        - filters    测试资源过滤文件
- it       集成测试
- assembly    assembly descriptors
- site    Site</code></pre></li>
<li>target<pre><code>- generated-sources
- classes
- generated-test-sources
- test-classes
- xxx.jar</code></pre></li>
<li>pom.xml</li>
<li>LICENSE.txt</li>
<li>NOTICE.txt</li>
<li>README.txt</li>
</ul>
<h3 id="3、打包时资源文件的配置"><a href="#3、打包时资源文件的配置" class="headerlink" title="3、打包时资源文件的配置"></a>3、打包时资源文件的配置</h3><h4 id="3-1、打包src-main-java目录下的xml"><a href="#3-1、打包src-main-java目录下的xml" class="headerlink" title="3.1、打包src/main/java目录下的xml"></a>3.1、打包src/main/java目录下的xml</h4><p>一般情况下，我们用到的资源文件(各种xml，properites，xsd文件等)都放在src/main/resources下面，利用maven打包时，maven能把这些资源文件打包到相应的jar或者war里。</p>
<p>有时候，比如mybatis的mapper.xml文件，我们习惯把它和Mapper.java放一起，都在src/main/java下面，这样利用maven打包时，就需要修改pom.xml文件，来把mapper.xml文件一起打包进jar或者war里了，否则，这些文件不会被打包的。(maven认为src/main/java只是java的源代码路径)</p>
<p>下面通过一个简单的示例来说明:</p>
<p>项目结构如下所示，有两个UserMaper.xml文件，所在目录不同</p>
<p><img src="1.png" alt="image"></p>
<p>默认情况下，在POM.XML目录下执行: mvn clean package 打包命令在target\classes目录下不会把UserMapper.xml打包到下mapper目录下</p>
<p><img src="2.png" alt="image"></p>
<p>而resources目录下的文件始终都会打包进jar包或war包</p>
<p><img src="3.png" alt="image"></p>
<p>这个时候使用mybatis就会出一些问题，找不到UserMapper所对应的xml文件解决方法有如下几种:</p>
<p><strong>(1)配置POM.XML的resource把xml也打包到mapper目录下</strong></p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 资源目录 --&gt;</span>    </span><br><span class="line">     <span class="tag">&lt;<span class="name">resources</span>&gt;</span>    </span><br><span class="line">         <span class="tag">&lt;<span class="name">resource</span>&gt;</span>    </span><br><span class="line">             <span class="comment">&lt;!-- 设定主资源目录  --&gt;</span>    </span><br><span class="line">             <span class="tag">&lt;<span class="name">directory</span>&gt;</span>src/main/java<span class="tag">&lt;/<span class="name">directory</span>&gt;</span>    </span><br><span class="line"> </span><br><span class="line">             <span class="comment">&lt;!-- maven default生命周期，process-resources阶段执行maven-resources-plugin插件的resources目标处理主资源目下的资源文件时，只处理如下配置中包含的资源类型 --&gt;</span>     </span><br><span class="line">	 <span class="tag">&lt;<span class="name">includes</span>&gt;</span></span><br><span class="line">		  <span class="tag">&lt;<span class="name">include</span>&gt;</span>**/*.xml<span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">	 <span class="tag">&lt;/<span class="name">includes</span>&gt;</span>  </span><br><span class="line">                  </span><br><span class="line">             <span class="comment">&lt;!-- maven default生命周期，process-resources阶段执行maven-resources-plugin插件的resources目标处理主资源目下的资源文件时，不处理如下配置中包含的资源类型（剔除下如下配置中包含的资源类型）--&gt;</span>      </span><br><span class="line">	<span class="tag">&lt;<span class="name">excludes</span>&gt;</span>  </span><br><span class="line">		<span class="tag">&lt;<span class="name">exclude</span>&gt;</span>**/*.yaml<span class="tag">&lt;/<span class="name">exclude</span>&gt;</span>  </span><br><span class="line">	<span class="tag">&lt;/<span class="name">excludes</span>&gt;</span>  </span><br><span class="line"> </span><br><span class="line">             <span class="comment">&lt;!-- maven default生命周期，process-resources阶段执行maven-resources-plugin插件的resources目标处理主资源目下的资源文件时，指定处理后的资源文件输出目录，默认是$&#123;build.outputDirectory&#125;指定的目录--&gt;</span>      </span><br><span class="line">             <span class="comment">&lt;!--&lt;targetPath&gt;$&#123;build.outputDirectory&#125;&lt;/targetPath&gt; --&gt;</span>      </span><br><span class="line"></span><br><span class="line">             <span class="comment">&lt;!-- maven default生命周期，process-resources阶段执行maven-resources-plugin插件的resources目标处理主资源目下的资源文件时，是否对主资源目录开启资源过滤 --&gt;</span>    </span><br><span class="line">             <span class="tag">&lt;<span class="name">filtering</span>&gt;</span>true<span class="tag">&lt;/<span class="name">filtering</span>&gt;</span>     </span><br><span class="line">         <span class="tag">&lt;/<span class="name">resource</span>&gt;</span>  			</span><br><span class="line">     <span class="tag">&lt;/<span class="name">resources</span>&gt;</span> 	</span><br><span class="line"><span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>其中**/*这样的写法，是为了保证各级子目录下的资源文件被打包。resources是可以看做是容器，这个容器里面可以放很多个像resource这样的配置。而directory就是配置文件所在的路径，includes从英文单词角度看，就是包含的意思，此时在执行命令，就会把xml也打包到mapper目录下了</p>
<p><img src="4.png" alt="image"></p>
<p>Resources官方文档地址为:<a href="http://maven.apache.org/pom.html#Resources" target="_blank" rel="noopener">http://maven.apache.org/pom.html#Resources</a></p>
<p><strong>(2)maven-resources-plugin插件</strong></p>
<p>为了使项目结构更为清晰，Maven区别对待Java代码文件和资源文件，maven-compiler-plugin用来编译Java代码，maven-resources-plugin则用来处理资源文件。</p>
<p>默认的主资源文件目录是src/main/resources，很多用户会需要添加额外的资源文件目录，这个时候就可以通过配置maven-resources-plugin来实现。</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">        此plugin可以用</span></span><br><span class="line"><span class="comment">        利用此plugin，把源代码中的xml文件，打包到相应位置，</span></span><br><span class="line"><span class="comment">        这里主要是为了打包Mybatis的mapper.xml文件</span></span><br><span class="line"><span class="comment">        --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-resources-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.5<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">id</span>&gt;</span>copy-xmls<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">phase</span>&gt;</span>process-sources<span class="tag">&lt;/<span class="name">phase</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">goal</span>&gt;</span>copy-resources<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">outputDirectory</span>&gt;</span>$&#123;basedir&#125;/target/classes<span class="tag">&lt;/<span class="name">outputDirectory</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">resources</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">resource</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">directory</span>&gt;</span>$&#123;basedir&#125;/src/main/java<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">includes</span>&gt;</span></span><br><span class="line">                            <span class="tag">&lt;<span class="name">include</span>&gt;</span>**/*.xml<span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;/<span class="name">includes</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;/<span class="name">resource</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">resources</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>此外，资源文件过滤也是Maven的一大特性，你可以在资源文件中使用${propertyName}形式的Maven属性，然后配置maven-resources-plugin开启对资源文件的过滤，之后就可以针对不同环境通过命令行或者Profile传入属性的值，以实现更为灵活的构建。</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-resources-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">encoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">encoding</span>&gt;</span></span><br><span class="line">		<span class="comment">&lt;!-- 过滤后缀为pem、pfx的证书文件 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">nonFilteredFileExtensions</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">nonFilteredFileExtension</span>&gt;</span>pem<span class="tag">&lt;/<span class="name">nonFilteredFileExtension</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">nonFilteredFileExtension</span>&gt;</span>pfx<span class="tag">&lt;/<span class="name">nonFilteredFileExtension</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">nonFilteredFileExtension</span>&gt;</span>p12<span class="tag">&lt;/<span class="name">nonFilteredFileExtension</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">nonFilteredFileExtensions</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>(3)build-helper-maven-plugin插件</strong></p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">      此plugin可以用</span></span><br><span class="line"><span class="comment">      利用此plugin，把源代码中的xml文件，</span></span><br><span class="line"><span class="comment">      打包到相应位置，这里主要是为了打包Mybatis的mapper.xml文件</span></span><br><span class="line"><span class="comment">      --&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.codehaus.mojo<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>build-helper-maven-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">                  <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">                      <span class="tag">&lt;<span class="name">id</span>&gt;</span>add-resource<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">                      <span class="tag">&lt;<span class="name">phase</span>&gt;</span>generate-resources<span class="tag">&lt;/<span class="name">phase</span>&gt;</span></span><br><span class="line">                      <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">                          <span class="tag">&lt;<span class="name">goal</span>&gt;</span>add-resource<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">                      <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">                      <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                          <span class="tag">&lt;<span class="name">resources</span>&gt;</span></span><br><span class="line">                              <span class="tag">&lt;<span class="name">resource</span>&gt;</span></span><br><span class="line">                                  <span class="tag">&lt;<span class="name">directory</span>&gt;</span>src/main/java<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">                                  <span class="tag">&lt;<span class="name">includes</span>&gt;</span></span><br><span class="line">                                      <span class="tag">&lt;<span class="name">include</span>&gt;</span>**/*.xml<span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">                                  <span class="tag">&lt;/<span class="name">includes</span>&gt;</span></span><br><span class="line">                              <span class="tag">&lt;/<span class="name">resource</span>&gt;</span></span><br><span class="line">                          <span class="tag">&lt;/<span class="name">resources</span>&gt;</span></span><br><span class="line">                      <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">                  <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h4 id="3-2、src-main-resources目录下的xml等资源文件不被打包"><a href="#3-2、src-main-resources目录下的xml等资源文件不被打包" class="headerlink" title="3.2、src/main/resources目录下的xml等资源文件不被打包"></a>3.2、src/main/resources目录下的xml等资源文件不被打包</h4><p>默认resources目录下的文件都会被打包，如果想resources目录下的xml文件不被打包，可通过如下配置:</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!--过滤resource下的文件--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">resources</span>&gt;</span>  </span><br><span class="line">       <span class="tag">&lt;<span class="name">resource</span>&gt;</span>  </span><br><span class="line">           <span class="tag">&lt;<span class="name">directory</span>&gt;</span>src/main/resources<span class="tag">&lt;/<span class="name">directory</span>&gt;</span>  </span><br><span class="line">           <span class="tag">&lt;<span class="name">includes</span>&gt;</span>  </span><br><span class="line">               <span class="tag">&lt;<span class="name">include</span>&gt;</span>*.properties<span class="tag">&lt;/<span class="name">include</span>&gt;</span>  <span class="comment">&lt;!--打包properties文件--&gt;</span></span><br><span class="line">           <span class="tag">&lt;/<span class="name">includes</span>&gt;</span>  </span><br><span class="line">           <span class="tag">&lt;<span class="name">excludes</span>&gt;</span>  </span><br><span class="line">               <span class="tag">&lt;<span class="name">exclude</span>&gt;</span>*.xml<span class="tag">&lt;/<span class="name">exclude</span>&gt;</span>  <span class="comment">&lt;!--过滤xml与yaml文件--&gt;</span></span><br><span class="line">               <span class="tag">&lt;<span class="name">exclude</span>&gt;</span>*.yaml<span class="tag">&lt;/<span class="name">exclude</span>&gt;</span>  </span><br><span class="line">           <span class="tag">&lt;/<span class="name">excludes</span>&gt;</span>  </span><br><span class="line">       <span class="tag">&lt;/<span class="name">resource</span>&gt;</span>  </span><br><span class="line">   <span class="tag">&lt;/<span class="name">resources</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>编译之后如下：</p>
<p><img src="5.png" alt="image"></p>
<p>当然也可以通过插件来实现</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span>  </span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-resources-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span>  </span><br><span class="line">    <span class="tag">&lt;<span class="name">executions</span>&gt;</span>  </span><br><span class="line">        <span class="tag">&lt;<span class="name">execution</span>&gt;</span>  </span><br><span class="line">            <span class="tag">&lt;<span class="name">id</span>&gt;</span>copy-resources<span class="tag">&lt;/<span class="name">id</span>&gt;</span>  </span><br><span class="line">            <span class="tag">&lt;<span class="name">phase</span>&gt;</span>validate<span class="tag">&lt;/<span class="name">phase</span>&gt;</span>  </span><br><span class="line">            <span class="tag">&lt;<span class="name">goals</span>&gt;</span>  </span><br><span class="line">                <span class="tag">&lt;<span class="name">goal</span>&gt;</span>copy-resources<span class="tag">&lt;/<span class="name">goal</span>&gt;</span>  </span><br><span class="line">            <span class="tag">&lt;/<span class="name">goals</span>&gt;</span>  </span><br><span class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span>  </span><br><span class="line"> </span><br><span class="line">	<span class="comment">&lt;!-- 并把文件复制到target/conf目录下--&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">outputDirectory</span>&gt;</span>$&#123;project.build.directory&#125;/conf<span class="tag">&lt;/<span class="name">outputDirectory</span>&gt;</span>  </span><br><span class="line">                <span class="tag">&lt;<span class="name">resources</span>&gt;</span>  </span><br><span class="line">                    <span class="tag">&lt;<span class="name">resource</span>&gt;</span>  </span><br><span class="line">                        <span class="tag">&lt;<span class="name">directory</span>&gt;</span>src/main/resources<span class="tag">&lt;/<span class="name">directory</span>&gt;</span>  </span><br><span class="line">			<span class="comment">&lt;!-- 指定不需要处理的资源 &lt;excludes&gt; &lt;exclude&gt;WEB-INF/*.*&lt;/exclude&gt; &lt;/excludes&gt; --&gt;</span>  </span><br><span class="line">			<span class="tag">&lt;<span class="name">excludes</span>&gt;</span> <span class="tag">&lt;<span class="name">exclude</span>&gt;</span>**/*.xml<span class="tag">&lt;/<span class="name">exclude</span>&gt;</span> <span class="tag">&lt;/<span class="name">excludes</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">filtering</span>&gt;</span>true<span class="tag">&lt;/<span class="name">filtering</span>&gt;</span>  </span><br><span class="line">                    <span class="tag">&lt;/<span class="name">resource</span>&gt;</span>  </span><br><span class="line">                <span class="tag">&lt;/<span class="name">resources</span>&gt;</span>  </span><br><span class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span>  </span><br><span class="line">        <span class="tag">&lt;/<span class="name">execution</span>&gt;</span>  </span><br><span class="line">    <span class="tag">&lt;/<span class="name">executions</span>&gt;</span>  </span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>实现的效果如下:</p>
<p><img src="6.png" alt="image"></p>
<p>编译好之后，会在target目录下生成conf目录并且把resources目录下的所有文件都自动拷贝到target/conf/目录下。</p>
<h3 id="4、补充Mybatis、MyBatisPlus-xml文件配置："><a href="#4、补充Mybatis、MyBatisPlus-xml文件配置：" class="headerlink" title="4、补充Mybatis、MyBatisPlus xml文件配置："></a>4、补充Mybatis、MyBatisPlus xml文件配置：</h3><p>默认配置是去Mapper.class 目录下找同名的xml文件，按照上文介绍，如果xml文件和java文件在一起，或者在resources下同名包下，如果通过注解指定了扫描Mapper的包地址，则无需配置xml文件地址。</p>
<p>如果不一致：则需要要指定扫描所在包的位置：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mybatis:</span><br><span class="line">  mapper-locations: classpath*:mapper/*.xml,classpath*:mapper/other/*.xml</span><br><span class="line"></span><br><span class="line">or</span><br><span class="line"></span><br><span class="line">mybatis-plus:</span><br><span class="line">  mapper-locations: classpath*:mapper/*.xml,classpath*:mapper/other/*.xml</span><br></pre></td></tr></table></figure>





      
    </div>
    <footer class="article-footer">
      <a data-url="https://bianchengme.gitee.io/2018/10/31/mybatis-plus-xml-%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E9%85%8D%E7%BD%AE/" data-id="cktcaskhy003i3guc7coa7ktb" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/" rel="tag">java</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-Markdown语法" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2018/03/30/Markdown%E8%AF%AD%E6%B3%95/" class="article-date">
  <time datetime="2018-03-30T04:15:14.000Z" itemprop="datePublished">2018-03-30</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Markdown/">Markdown</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2018/03/30/Markdown%E8%AF%AD%E6%B3%95/">Markdown语法</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>用Markdown写文章是程序员的最爱，那什么是Markdown？</p>
<h2 id="Markdown"><a href="#Markdown" class="headerlink" title="Markdown"></a>Markdown</h2><p>Markdown 是一种轻量级标记语言，创始人为约翰·格鲁伯和亚伦·斯沃茨。它允许人们“使用易读易写的纯文本格式编写文档，然后转换成有效的XHTML文档”。 ——维基百科</p>
<p>Markdown具有一系列衍生版本，用于扩展Markdown的功能（如表格、脚注、内嵌HTML等等），这些功能原初的Markdown尚不具备，它们能让Markdown转换成更多的格式，例如LaTeX，Docbook。Markdown增强版中比较有名的有Markdown Extra、MultiMarkdown、 Maruku等。</p>
<p>你可以使用vim工具直接编辑md文件，也可以用记事本打开md文件编辑你的文章，也可以Markdown的编辑器编写，有很多在线的编辑器，还有不少客户端的编辑器，我是Mac系统，用的一个叫 Mou 的编辑器，还比较好使。Windows系统下，你可以自己找一下，应该也会有很好用的编辑器。</p>
<p>先简单介绍一下，Markdown的语法，具体怎么用，我相信大家一看例文就马上明白了。</p>
<h3 id="斜体"><a href="#斜体" class="headerlink" title="斜体"></a>斜体</h3><p>代码</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">*斜体* 或者 _斜体_</span><br></pre></td></tr></table></figure>

<p>效果</p>
<p><em>斜体</em></p>
<h3 id="粗体"><a href="#粗体" class="headerlink" title="粗体"></a>粗体</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">**粗体**  或者   __粗体__</span><br></pre></td></tr></table></figure>

<p>效果</p>
<p><em>**粗体</em></p>
<h3 id="标题"><a href="#标题" class="headerlink" title="标题"></a>标题</h3><p>可以在标题内容前输入特定数量的’#’来实现对应级别的HTML样式的标题。<br></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"># 一级标题</span><br><span class="line">## 二级标题</span><br><span class="line">### 三级标题</span><br><span class="line">#### 四级标题</span><br><span class="line">##### 五级标题</span><br><span class="line">###### 六级标题</span><br></pre></td></tr></table></figure>

<p>效果</p>
<h1 id="一级标题"><a href="#一级标题" class="headerlink" title="一级标题"></a>一级标题</h1><h2 id="二级标题"><a href="#二级标题" class="headerlink" title="二级标题"></a>二级标题</h2><h3 id="三级标题"><a href="#三级标题" class="headerlink" title="三级标题"></a>三级标题</h3><h4 id="四级标题"><a href="#四级标题" class="headerlink" title="四级标题"></a>四级标题</h4><h5 id="五级标题"><a href="#五级标题" class="headerlink" title="五级标题"></a>五级标题</h5><h6 id="六级标题"><a href="#六级标题" class="headerlink" title="六级标题"></a>六级标题</h6><p>一级和二级标题还有一种写法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">一级标题</span><br><span class="line">&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D; </span><br><span class="line">二级标题</span><br><span class="line">--------------------</span><br></pre></td></tr></table></figure>

<h3 id="换行"><a href="#换行" class="headerlink" title="换行"></a>换行</h3><p>行尾输入两个或以上的空格，然后回车。或者行尾加上&lt;br&gt;。</p>
<h4 id="引用"><a href="#引用" class="headerlink" title="引用"></a>引用</h4><p> 引用只需要在被引用的内容段落开头加上右尖括号&gt;即可。你可以选择只在开头加一个。也可以在每行前面都加一个，效果是一样的。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">&gt; 这一整段的内容都会作为一个HTML的引用元素。</span><br><span class="line">引用元素是会自动优化排版的（reflowable，可回流）。</span><br><span class="line">你可以任意地将引用的内容包含进来，然后所有这些都会</span><br><span class="line">被解析成为单独一个引用元素。</span><br></pre></td></tr></table></figure>

<p>效果</p>
<blockquote>
<p>这一整段的内容都会作为一个HTML的引用元素。<br>引用元素是会自动优化排版的（reflowable，可回流）。<br>你可以任意地将引用的内容包含进来，然后所有这些都会<br>被解析成为单独一个引用元素。</p>
</blockquote>
<p> 引用可以嵌套。如果要在一个引用里插入一个引用，可以用两个&gt;开头。依此类推，根据嵌套层次加相应数量的符号。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">&gt; 这是一个引用。这是第一行</span><br><span class="line">这是第二行。</span><br><span class="line">&gt;&gt; 这是一个嵌套的引用。这是第一行。</span><br><span class="line">这是第二行</span><br><span class="line">&gt; </span><br><span class="line">&gt; 外层引用的第三行。前面需要一个视觉上的空行表示内层嵌套的结束，空行前面的&gt;可以有可以没有。</span><br></pre></td></tr></table></figure>

<p>效果</p>
<blockquote>
<p>这是一个引用。这是第一行<br> 这是第二行。</p>
<blockquote>
<p>这是一个嵌套的引用。这是第一行。<br> 这是第二行</p>
</blockquote>
<p>外层引用的第三行。前面需要一个视觉上的空行表示内层嵌套的结束，空行前面的&gt;可以有可以没有。</p>
</blockquote>
<h3 id="链接"><a href="#链接" class="headerlink" title="链接"></a>链接</h3><p>链接可以在行内插入：</p>
<p> <a href="链接地址">链接文字</a></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[Markdown](http:&#x2F;&#x2F;zh.wikipedia.com&#x2F;wiki&#x2F;Markdown)</span><br></pre></td></tr></table></figure>

<p>效果</p>
<p><a href="http://zh.wikipedia.com/wiki/Markdown" target="_blank" rel="noopener">Markdown</a></p>
<h3 id="水平分区线"><a href="#水平分区线" class="headerlink" title="水平分区线"></a>水平分区线</h3><p> 要生成水平分区线，可以在单独一行里输入3个或以上的短横线、星号或者下划线实现。短横线和星号之间可以输入任意空格。以下每一行都产生一条水平分区线。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">* * *</span><br><span class="line">***</span><br><span class="line">*****</span><br><span class="line">- - -</span><br><span class="line">---------------------------------------</span><br></pre></td></tr></table></figure>

<p>效果</p>
<hr>
<h3 id="图片"><a href="#图片" class="headerlink" title="图片"></a>图片</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">![Foo](http:&#x2F;&#x2F;i.weather.com.cn&#x2F;images&#x2F;cn&#x2F;life&#x2F;2017&#x2F;04&#x2F;11&#x2F;11141533DF572FBBA092E37E6E843C656C318272.jpg)</span><br></pre></td></tr></table></figure>

<p>效果</p>
<p><img src="http://i.weather.com.cn/images/cn/life/2017/04/11/11141533DF572FBBA092E37E6E843C656C318272.jpg" alt="Foo"></p>
<p>列表</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">无序列表</span><br><span class="line"> 使用 *，+，- 表示无序列表。</span><br><span class="line"></span><br><span class="line"> + 无序列表项 一</span><br><span class="line">    - 子无序列表 一</span><br><span class="line">    - 子无序列表 二</span><br><span class="line">        * 子无序列表 三</span><br><span class="line"> + 无序列表项 二</span><br><span class="line"> + 无序列表项 三</span><br><span class="line">有序列表</span><br><span class="line"> 使用数字和点表示有序列表。</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"> 1. 有序列表项 一</span><br><span class="line">    1. 子有序列表项 一</span><br><span class="line">    2. 子有序列表项 二</span><br><span class="line"> 2. 有序列表项 二</span><br><span class="line"> 3. 有序列表项 三</span><br></pre></td></tr></table></figure>

<p>效果</p>
<p>无序列表</p>
<p>使用 *，+，- 表示无序列表。</p>
<ul>
<li>无序列表项 一<ul>
<li>子无序列表 一</li>
<li>子无序列表 二<ul>
<li>子无序列表 三</li>
</ul>
</li>
</ul>
</li>
<li>无序列表项 二</li>
<li>无序列表项 三</li>
</ul>
<p>有序列表</p>
<p>使用数字和点表示有序列表。</p>
<ol>
<li>有序列表项 一<ol>
<li>子有序列表项 一</li>
<li>子有序列表项 二</li>
</ol>
</li>
<li>有序列表项 二</li>
<li>有序列表项 三</li>
</ol>
<h3 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h3><p>行内代码快：代码用`包括<br>效果</p>
<p> <code>代码</code></p>
<p>代码块及代码高亮：<br> 在4个`后加上语言类型，高亮显示代码</p>
<p> (4个`)(语言类型)</p>
<p> 代码</p>
<p> (4个`)</p>
<h2 id="Markdown语法进阶"><a href="#Markdown语法进阶" class="headerlink" title="Markdown语法进阶"></a>Markdown语法进阶</h2><h3 id="字符转义"><a href="#字符转义" class="headerlink" title="字符转义"></a>字符转义</h3><p>Markdown中的转义字符为\，可以转义的有：</p>
<p>\ 反斜杠<br>` 反引号<br>* 星号<br>_ 下划线<br>{} 大括号<br>[] 中括号<br>() 小括号<br># 井号<br>+ 加号<br>- 减号<br>. 英文句号<br>! 感叹号  </p>
<h3 id="删除线"><a href="#删除线" class="headerlink" title="删除线"></a>删除线</h3><p>使用 ~~ 包括一段话表示删除线。</p>
<p> <del>这是一段错误的文本。</del></p>
<h3 id="表格"><a href="#表格" class="headerlink" title="表格"></a>表格</h3><h4 id="单元格和表头"><a href="#单元格和表头" class="headerlink" title="单元格和表头"></a>单元格和表头</h4><p> 使用 | 来分隔不同的单元格，使用 - 来分隔表头和其他行：  </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">name | age</span><br><span class="line">---- | ---</span><br><span class="line">LearnShare | 12</span><br><span class="line">Mike |  32</span><br></pre></td></tr></table></figure>

<p>效果  </p>
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody><tr>
<td>LearnShare</td>
<td>12</td>
</tr>
<tr>
<td>Mike</td>
<td>32</td>
</tr>
</tbody></table>
<h4 id="对齐"><a href="#对齐" class="headerlink" title="对齐"></a>对齐</h4><p>在表头下方的分隔线标记中加入 :，即可标记下方单元格内容的对齐方式：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">:--- 代表左对齐  </span><br><span class="line">:--: 代表居中对齐  </span><br><span class="line">---: 代表右对齐</span><br></pre></td></tr></table></figure>

<table>
<thead>
<tr>
<th align="left">left</th>
<th align="center">center</th>
<th align="right">right</th>
</tr>
</thead>
<tbody><tr>
<td align="left">aaaa</td>
<td align="center">bbbbbb</td>
<td align="right">ccccc</td>
</tr>
<tr>
<td align="left">a</td>
<td align="center">b</td>
<td align="right">c</td>
</tr>
</tbody></table>
<h4 id="插入其他内容"><a href="#插入其他内容" class="headerlink" title="插入其他内容"></a>插入其他内容</h4><p> 表格中可以插入其他 Markdown 中的行内标记：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">|     name     |             URL                |</span><br><span class="line">| ------------ | ------------------------------- |</span><br><span class="line">| _Google_     | ![Google](https:&#x2F;&#x2F;www.google.com&#x2F;images&#x2F;branding&#x2F;googlelogo&#x2F;1x&#x2F;googlelogo_color_272x92dp.png)     |</span><br><span class="line">| __YouTube__   | [YouTube](https:&#x2F;&#x2F;www.youtube.com&#x2F;) |</span><br></pre></td></tr></table></figure>

<p>效果   </p>
<table>
<thead>
<tr>
<th>name</th>
<th>URL</th>
</tr>
</thead>
<tbody><tr>
<td><em>Google</em></td>
<td><img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Google"></td>
</tr>
<tr>
<td><strong>YouTube</strong></td>
<td><a href="https://www.youtube.com/" target="_blank" rel="noopener">YouTube</a></td>
</tr>
</tbody></table>
<h3 id="Html-标签"><a href="#Html-标签" class="headerlink" title="Html 标签"></a>Html 标签</h3><p> 支持在 Markdown 语法中嵌套 Html 标签</p>
<h3 id="选框"><a href="#选框" class="headerlink" title="选框"></a>选框</h3><p>使用带有 - [ ] 或 - [x] （未完成或已完成）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">- [ ] 未选</span><br><span class="line">- [x] 选中</span><br></pre></td></tr></table></figure>

<p>效果</p>
<ul>
<li><input disabled="" type="checkbox"> 未选</li>
<li><input checked="" disabled="" type="checkbox"> 选中</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://bianchengme.gitee.io/2018/03/30/Markdown%E8%AF%AD%E6%B3%95/" data-id="cktcaskhe00163guc9b4wf9zo" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Markdown/" rel="tag">Markdown</a></li></ul>

    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    
    <a class="extend prev" rel="prev" href="/page/5/">&amp;laquo; Prev</a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/4/">4</a><a class="page-number" href="/page/5/">5</a><span class="page-number current">6</span>
  </nav>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Docker/">Docker</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/Docker/Nacos/">Nacos</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Docker/mysql/">mysql</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/JAVA/">JAVA</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/JAVA/JVM/">JVM</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/Markdown/">Markdown</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Windows/">Windows</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/">docker</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/docker/redis/">redis</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/flutter/">flutter</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/git/">git</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/iOS/">iOS</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/iOS/Objective-C/">Objective-C</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/iOS/Xcode/">Xcode</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/java/">java</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/java/%E5%A4%9A%E7%BA%BF%E7%A8%8B/">多线程</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/mysql/">mysql</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/vue/">vue</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/BUG/" rel="tag">BUG</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Docker/" rel="tag">Docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JAVA/" rel="tag">JAVA</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JVM/" rel="tag">JVM</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Markdown/" rel="tag">Markdown</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Objective-C/" rel="tag">Objective-C</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/RunTime/" rel="tag">RunTime</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Swift/" rel="tag">Swift</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/UI/" rel="tag">UI</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Windows/" rel="tag">Windows</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Xcode/" rel="tag">Xcode</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/" rel="tag">docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flutter/" rel="tag">flutter</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/" rel="tag">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hook/" rel="tag">hook</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/iOS/" rel="tag">iOS</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/iOS%E7%9C%9F%E6%9C%BA%E8%BF%90%E8%A1%8C/" rel="tag">iOS真机运行</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/" rel="tag">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mysl/" rel="tag">mysl</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mysql/" rel="tag">mysql</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nacos/" rel="tag">nacos</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/" rel="tag">redis</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/volatile/" rel="tag">volatile</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vue/" rel="tag">vue</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E4%BC%98%E5%8C%96/" rel="tag">优化</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" rel="tag">多线程</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%AD%A6%E4%B9%A0%E8%AE%A1%E5%88%92/" rel="tag">学习计划</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%B7%A5%E5%85%B7/" rel="tag">工具</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B/" rel="tag">并发编程</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%BD%91%E7%BB%9C/" rel="tag">网络</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E9%83%A8%E7%BD%B2/" rel="tag">部署</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E9%9D%A2%E8%AF%95/" rel="tag">面试</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/BUG/" style="font-size: 10px;">BUG</a> <a href="/tags/Docker/" style="font-size: 10px;">Docker</a> <a href="/tags/JAVA/" style="font-size: 10px;">JAVA</a> <a href="/tags/JVM/" style="font-size: 10px;">JVM</a> <a href="/tags/Markdown/" style="font-size: 10px;">Markdown</a> <a href="/tags/Objective-C/" style="font-size: 16.67px;">Objective-C</a> <a href="/tags/RunTime/" style="font-size: 10px;">RunTime</a> <a href="/tags/Swift/" style="font-size: 10px;">Swift</a> <a href="/tags/UI/" style="font-size: 13.33px;">UI</a> <a href="/tags/Windows/" style="font-size: 10px;">Windows</a> <a href="/tags/Xcode/" style="font-size: 10px;">Xcode</a> <a href="/tags/docker/" style="font-size: 13.33px;">docker</a> <a href="/tags/flutter/" style="font-size: 13.33px;">flutter</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/hook/" style="font-size: 10px;">hook</a> <a href="/tags/iOS/" style="font-size: 20px;">iOS</a> <a href="/tags/iOS%E7%9C%9F%E6%9C%BA%E8%BF%90%E8%A1%8C/" style="font-size: 10px;">iOS真机运行</a> <a href="/tags/java/" style="font-size: 16.67px;">java</a> <a href="/tags/mysl/" style="font-size: 10px;">mysl</a> <a href="/tags/mysql/" style="font-size: 10px;">mysql</a> <a href="/tags/nacos/" style="font-size: 10px;">nacos</a> <a href="/tags/redis/" style="font-size: 10px;">redis</a> <a href="/tags/volatile/" style="font-size: 10px;">volatile</a> <a href="/tags/vue/" style="font-size: 10px;">vue</a> <a href="/tags/%E4%BC%98%E5%8C%96/" style="font-size: 10px;">优化</a> <a href="/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" style="font-size: 10px;">多线程</a> <a href="/tags/%E5%AD%A6%E4%B9%A0%E8%AE%A1%E5%88%92/" style="font-size: 10px;">学习计划</a> <a href="/tags/%E5%B7%A5%E5%85%B7/" style="font-size: 10px;">工具</a> <a href="/tags/%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B/" style="font-size: 10px;">并发编程</a> <a href="/tags/%E7%AE%97%E6%B3%95/" style="font-size: 10px;">算法</a> <a href="/tags/%E7%BD%91%E7%BB%9C/" style="font-size: 10px;">网络</a> <a href="/tags/%E9%83%A8%E7%BD%B2/" style="font-size: 10px;">部署</a> <a href="/tags/%E9%9D%A2%E8%AF%95/" style="font-size: 10px;">面试</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/09/">September 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/07/">July 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/06/">June 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/05/">May 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/03/">March 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/10/">October 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/09/">September 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/08/">August 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/07/">July 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/05/">May 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/04/">April 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/03/">March 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">June 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">May 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">April 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">March 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/02/">February 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/10/">October 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/03/">March 2018</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2021/09/07/JVM-%E9%80%83%E9%80%B8%E5%88%86%E6%9E%90%E4%BC%98%E5%8C%96/">JVM 逃逸分析优化</a>
          </li>
        
          <li>
            <a href="/2021/07/02/Nacos%E9%80%9A%E8%BF%87Docke%E9%83%A8%E7%BD%B2/">Nacos通过Docke部署</a>
          </li>
        
          <li>
            <a href="/2021/07/01/Docker%E5%AE%89%E8%A3%85mysql5-7/">Docker安装mysql5.7</a>
          </li>
        
          <li>
            <a href="/2021/07/01/Docker%E5%AE%89%E8%A3%85redis/">Docker安装redis</a>
          </li>
        
          <li>
            <a href="/2021/06/30/Java%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B-volatile%E5%85%B3%E9%94%AE%E5%AD%97%E7%90%86%E8%A7%A3/">Java并发编程-volatile关键字理解</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2021 jmme@foxmail.com<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>




  </div>
</body>
</html>